camera lib区分版本,按版本升级

chengzhenyu 7 anni fa
parent
commit
dc6892eb6c

+ 4 - 3
app/src/main/java/ai/pai/lensman/App.java

@@ -38,6 +38,8 @@ public class App extends Application{
38 38
         return mInstance;
39 39
     }
40 40
 
41
+    private static final int CAMERA_LIB_VERSION = 1;
42
+
41 43
     @Override
42 44
     public void onCreate() {
43 45
         super.onCreate();
@@ -118,7 +120,7 @@ public class App extends Application{
118 120
         String rawSoFilePath = tmpLibDirPath + File.separator + "camera.so";
119 121
         deleteDir(new File(unzipPath));
120 122
         new File(rawSoFilePath).delete();
121
-        if(Preferences.getInstance().isCameraLibExist()){
123
+        if(Preferences.getInstance().getCameraLibVersion()>=CAMERA_LIB_VERSION){
122 124
             return ;
123 125
         }
124 126
         copyRawLibToSdcard(tmpLibDirPath);
@@ -178,10 +180,9 @@ public class App extends Application{
178 180
                     os.flush();
179 181
                     process.waitFor();
180 182
                     LogHelper.d("czy","camera lib so install success");
181
-                    Preferences.getInstance().setCameraLibExist(true);
183
+                    Preferences.getInstance().setCameraLibVersion(CAMERA_LIB_VERSION);
182 184
                 } catch (Exception e) {
183 185
                     LogHelper.d("czy","camera lib so install error-->"+e);
184
-                    Preferences.getInstance().setCameraLibExist(false);
185 186
                 } finally {
186 187
                     try {
187 188
                         if (os != null) {

+ 5 - 4
app/src/main/java/ai/pai/lensman/db/Preferences.java

@@ -57,12 +57,13 @@ public class Preferences {
57 57
         mPrefs.edit().putString("wxcode",wxCode).commit();
58 58
     }
59 59
 
60
-    public boolean isCameraLibExist(){
61
-        return mPrefs.getBoolean("CameraLibExist",false);
60
+
61
+    public void setCameraLibVersion(int version){
62
+        mPrefs.edit().putInt("cameraLibVer",version).commit();
62 63
     }
63 64
 
64
-    public void setCameraLibExist(boolean CameraLibExist){
65
-        mPrefs.edit().putBoolean("CameraLibExist",CameraLibExist).commit();
65
+    public int getCameraLibVersion(){
66
+        return mPrefs.getInt("cameraLibVer",0);
66 67
     }
67 68
 
68 69
     public void setPatchUrl(String patchUrl){